package com.zhangqiang.git.cloud.oauth.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * @ClassName: OAuth2ResourceServer
 * @Description: 资源服务
 * @author: zhangqiang
 * @date: 2021/3/1
 *
 */
@Configuration
@EnableResourceServer
public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
	@Override
	public void configure(HttpSecurity http) throws Exception {
		// 配置需oauth2 token验证的请求
		http.antMatcher("/oauth2/**")
				.authorizeRequests()

				// 无需验证的请求地址
				.antMatchers("/oauth2/demo").permitAll()
				.anyRequest().authenticated();
	}
}
